package com.iwhalecloud.bss.kite.cucc.service.attr.linkhandler;

import com.iwhalecloud.bss.kite.cucc.service.attr.LocalAttrHelper;
import com.iwhalecloud.bss.kite.cucc.service.attr.handler.PCRFSwitchAttrHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.annotation.AttrHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.impl.AbstractAttrLinkageHandler;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteInst;
import com.iwhalecloud.bss.kite.service.attr.AttrData;
import org.springframework.stereotype.Service;

import java.util.Objects;

@Service
@AttrHandler(PCRFSwitchAttrHandler.class)
public class PCRFSwitchAttrLinkHandler extends AbstractAttrLinkageHandler<AttrData> {

    @Override
    public void handle(KiteAttr attr, KiteInst inst, AttrData data) {
        // 使用PCRF选择否时,附件要删除
        KiteAttr attachment = inst.getAttr("200004167");
        if ("1_0000107".equals(attr.getValue())) {
            if (Objects.nonNull(attachment)) {
                attachment.setShowType("E");
                attachment.setValue(null);
                attachment.setValueDesc(null);
            }
        } else {
            LocalAttrHelper.showAndNotNull(inst, "200004167");
        }
    }

    @Override
    public void handleStyle(KiteAttr attr, KiteInst inst, AttrData data) {

    }
}
